home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / LISTIT~1.CLS < prev    next >
Text File  |  1997-06-14  |  2KB  |  61 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "CListItemWalker"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Option Explicit
  11.  
  12. ' Implement Basic-friendly version of IEnumVARIANT
  13. Implements IVariantWalker
  14. ' Delegate to class that implements real IEnumVARIANT
  15. Private vars As CEnumVariant
  16. ' Connect back to parent collection
  17. Private connect As XListBoxPlus
  18.  
  19. ' Private state data
  20. Private iCur As Long
  21.  
  22. Private Sub Class_Initialize()
  23.     ' Initialize position in collection
  24.     iCur = 0
  25.     ' Connect walker to CEnumVariant so it can call methods
  26.     Set vars = New CEnumVariant
  27.     vars.Attach Me
  28. End Sub
  29.  
  30. ' Receive connection from XListBoxPlus
  31. Sub Attach(connectA As XListBoxPlus)
  32.     Set connect = connectA
  33. End Sub
  34.  
  35. ' Return IEnumVARIANT (indirectly) to client collection
  36. Friend Function NewEnum() As stdole.IEnumVARIANT
  37.     Set NewEnum = vars
  38. End Function
  39.  
  40. ' Implement IVariantWalker methods
  41. Private Function IVariantWalker_More(v As Variant) As Boolean
  42.     ' Move to next element
  43.     iCur = iCur + 1
  44.     ' If more data, return True and update data
  45.     If iCur <= connect.Count Then
  46.         IVariantWalker_More = True
  47.         v = connect.ListItems(iCur)
  48.     End If
  49. End Function
  50.  
  51. Private Sub IVariantWalker_Reset()
  52.     ' Move to first element
  53.     iCur = 0
  54. End Sub
  55.  
  56. Private Sub IVariantWalker_Skip(c As Long)
  57.     ' Skip a given number of elements
  58.     iCur = iCur + c
  59. End Sub
  60.  
  61.